library reminder;

import 'package:base_lib/common/index.dart';
import 'package:flutter/material.dart';

///全局轻提示
class Reminder {
  static bool isUseToastyDefault = false;

  static void show(String content,
      {Duration duration = const Duration(seconds: 3),
      textColor: Colors.white,
      bgColor: Colors.black54,
      Alignment alignment = Alignment.center,
      bool isUseToasty}) {
    isUseToasty ?? isUseToastyDefault
        ? toast(content,
            duration: duration,
            themeData: ToastThemeData.raw(
                textColor: textColor,
                background: bgColor,
                alignment: alignment))
        : showSimpleNotification(
            Center(
              child: Text(
                content,
                style: TextStyle(color: textColor),
              ),
            ),
            background: bgColor,
            autoDismiss: true,
            duration: duration,
            position: (alignment == Alignment.bottomLeft ||
                    alignment == Alignment.bottomCenter ||
                    alignment == Alignment.bottomRight)
                ? NotificationPosition.bottom
                : NotificationPosition.top,
            slideDismiss: true);
  }

  static void info(String content,
      {Duration duration = const Duration(seconds: 3),
      textColor: Colors.white,
      bgColor: Colors.black54,
      Alignment alignment = Alignment.center,
      bool isUseToasty}) {
    show(content,
        duration: duration,
        textColor: textColor,
        bgColor: bgColor,
        alignment: alignment,
        isUseToasty: isUseToasty);
  }

  static void waring(String content,
      {Duration duration = const Duration(seconds: 3),
      textColor: Colors.black,
      bgColor: Colors.yellow,
      Alignment alignment = Alignment.center,
      bool isUseToasty}) {
    show(content,
        duration: duration,
        textColor: textColor,
        bgColor: bgColor,
        alignment: alignment,
        isUseToasty: isUseToasty);
  }

  static void success(String content,
      {Duration duration = const Duration(seconds: 3),
      textColor: Colors.white,
      bgColor: Colors.blue,
      Alignment alignment = Alignment.center,
      bool isUseToasty}) {
    show(content,
        duration: duration,
        textColor: textColor,
        bgColor: bgColor,
        alignment: alignment,
        isUseToasty: isUseToasty);
  }

  static void error(String content,
      {Duration duration = const Duration(seconds: 3),
      textColor: Colors.white,
      bgColor: Colors.red,
      Alignment alignment = Alignment.center,
      bool isUseToasty}) {
    show(content,
        duration: duration,
        textColor: textColor,
        bgColor: bgColor,
        alignment: alignment,
        isUseToasty: isUseToasty);
  }
}
